from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *

import sys

class QLineEditDemo(QWidget):
    def __init__(self):
        super(QLineEditDemo, self).__init__()
        self.initUI()
    def initUI(self):

        self.setWindowTitle("QLineEdit integrel")

        edit1 = QLineEdit()
        edit1.setValidator(QIntValidator())
        edit1.setMaxLength(4)
        edit1.setAlignment(Qt.AlignLeft)
        edit1.setFont(QFont('Arial', 20))



        edit2 = QLineEdit()
        edit2.setValidator(QDoubleValidator(0.01,99.99, 2))
        # edit1.setMaxLength(4)
        edit2.setAlignment(Qt.AlignLeft)
        edit2.setFont(QFont('Arial', 20))

        edit3 = QLineEdit()
        edit3.setInputMask('99-999-9999;#')

        edit4 = QLineEdit()
        edit4.textChanged.connect(self.textChanged)

        edit5 = QLineEdit()
        edit5.setEchoMode(QLineEdit.Password)
        edit5.editingFinished.connect(self.textChanged)



        formLayout = QFormLayout()
        formLayout.addRow('整数校验', edit1)
        formLayout.addRow('浮点校验', edit2)
        formLayout.addRow('掩码校验', edit3)
        formLayout.addRow('文本变化', edit4)
        formLayout.addRow("密码输入", edit5)
        self.setLayout(formLayout)

    def textChanged(self, text):

        print("输入的内容:", text)

    def enterPress(self):
        print("已输入值")




if __name__ == '__main__':

    app = QApplication(sys.argv)
    ex = QLineEditDemo()
    ex.show()

    sys.exit(app.exec_())